(function() {
    "use strict";
    var e = window.jQuery,
        t = window.qh360cp,
        n = window._,
        r = {
            compareResult: function(r) {
                var i = t.QFilter,
                    s = r.xValue.data,
                    o = i.options.lotID;
                if (o == "110033" || o == "210053") {
                    i.compare_sdp3(o, s);
                    return
                }
                var u = function() {
                        var n = {
                            LotID: o,
                            IssueCount: e('.method [type="radio"]:checked').val(),
                            TopCount: 5,
                            Chips: s
                        };
                        e(".compare-tips:eq(2)").show().siblings().hide(), e.post("/tools/getCompareResult", n, function(r) {
                            if (n.IssueCount != e('.method [type="radio"]:checked').val()) return;
                            if (r.code == 200) {
                                e(".compare-result h4 b").text(r.data.issueCount);
                                var r = r.data.result,
                                    i = [];
                                if (r.length == 0) i.push('<li class="ta-c muted">\u4f60\u9009\u62e9\u7684\u53f7\u7801\u5728\u6240\u9009\u7684\u671f\u6b21\u8303\u56f4\u5185\u8fd8\u6ca1\u6709\u4e2d\u8fc7\u5956\uff01</li>');
                                else
                                    for (var s = 0, u = r.length; s < u; s++) {
                                        i.push("<li>"), i.push("<p>"), i.push('<i class="ico ico-libefore"></i>'), i.push('<span class="number">' + r[s].levelName + '\uff1a<b class="red">' + r[s].total + "</b>\u6b21</span>"), i.push('<span class="bonus-hign">\u5355\u6ce8\u6700\u9ad8\u5956\u91d1\uff1a<b>' + t.number.currency(r[s].max) + "</b>\u5143</span>"), i.push('<i class="ico ico-liafter" title="\u70b9\u51fb\u5c55\u5f00"></i>'), i.push("</p>"), i.push('<div class="code-show">'), i.push('<span class="coner"></span>'), i.push("<ul>");
                                        var a = r[s].detail;
                                        for (var f = 0, l = a.length; f < l; f++) {
                                            var c;
                                            o == "220051" ? c = h(n.Chips, a[f].winno, r[s].level) : o == "120029" ? c = p(n.Chips, a[f].winno, r[s].level) : o == "220028" && (c = d(n.Chips, a[f].winno, r[s].level));
                                            var v = a[f].winno.split("+"),
                                                m = v[0].split(" ");
                                            if (o != "220051") var g = v[1].split(" ");
                                            i.push("<li>"), i.push('<span class="date">' + a[f].issue + "\u671f\u5f00\u5956</span>"), i.push('<span class="numlist">');
                                            for (var y = 0, b = m.length; y < b; y++) {
                                                var w = m[y];
                                                i.push("<em" + (e.inArray(w, c.red) > -1 ? ' class="red">' : ">") + w + "</em> ")
                                            }
                                            if (o != "220051") {
                                                i.push("|&nbsp;");
                                                for (var y = 0, b = g.length; y < b; y++) {
                                                    var w = g[y];
                                                    i.push("<em" + (e.inArray(w, c.blue) > -1 ? ' class="blue">' : ">") + w + "</em> ")
                                                }
                                            } else i.push("| <em" + (e.inArray(v[1], c.blue) > -1 ? ' class="blue">' : ">") + v[1] + "</em>");
                                            i.push("</span>"), i.push('<span class="bonus">\u5956\u91d1\uff1a' + t.number.currency(a[f].bonus) + "\u5143</span>"), i.push("</li>")
                                        }
                                        f > 4 && i.push('<li class="muted">\u6700\u591a\u663e\u793a5\u671f<li>'), i.push("</ul>"), i.push("</div>"), i.push("</li>")
                                    }
                                e(".compare-list").html(i.join("")), e(".compare-tips").hide(), e(".compare-result").show(), e(".compare-list>li>p").on("click", function(t) {
                                    t.preventDefault(), e(this).parent().toggleClass("active").siblings().removeClass("active").find(".ico-liafter").attr("title", "\u70b9\u51fb\u5c55\u5f00"), e(this).find(".ico-liafter").attr("title", e(this).parent().hasClass("active") ? "\u70b9\u51fb\u6536\u8d77" : "\u70b9\u51fb\u5c55\u5f00")
                                })
                            }
                        })
                    },
                    a = function() {
                        e('.method [type="radio"]').on("change", function() {
                            var t = e(this).val() == "0" ? "\u5386\u53f2\u6240\u6709" : "\u6700\u8fd1" + e(this).val();
                            e(".compare-result").hide(), e(".compare-tips:eq(1)").find(".ta-c em").text(t).end().show().siblings().hide(), e(".panel-compare .btn-slt-ok").removeClass("disable")
                        }), e(".panel-compare .btn-slt-ok").on("click", function(t) {
                            t.preventDefault();
                            if (e(this).hasClass("disable")) return;
                            u(), e(this).addClass("disable")
                        })
                    },
                    f = function() {
                        var r = [],
                            i = 0,
                            o = s.split(";"),
                            u = o.length,
                            a = 0,
                            f = [];
                        for (; a < u; a++) {
                            var l = "\u5355\u5f0f",
                                c = 1,
                                h = o[a].split("+"),
                                p = h[0],
                                d = h[1],
                                v = p.split(" ").length,
                                m = d.split(" ").length;
                            if (p.indexOf("$") > -1) {
                                var g = p.split("$"),
                                    y = g[0].split(" ").length,
                                    b = g[1].split(" ").length;
                                l = "\u80c6\u62d6", c = t.number.combo(b, 6 - y) * m, console.log(y)
                            } else v > 6 || m > 1 ? (l = "\u590d\u5f0f", c = t.number.combo(v, 6) * m) : (l = "\u5355\u5f0f", c = 1);
                            f.push(l);
                            var w = {
                                plays: l,
                                count: c,
                                money: c * 2,
                                code: o[a],
                                red: p,
                                blue: d
                            };
                            i += c;
                            var E = '<li codes="<%=code%>"><div class="code"><b><%=plays%></b><b class="em"><%=red%> + <b class="blue"><%=blue%></b></b>  [<%=count%>\u6ce8,<em class="code-list-money"><%=money%></em>\u5143]</div></li>',
                                S = n.template(E);
                            r.push(S(w))
                        }
                        var x = n.uniq(f),
                            T;
                        x.length > 1 ? T = "\u6df7\u6295" : T = x[0], e(".dbq-plays").html(T), e(".dbq-count").html(i), e(".dbq-money").html(i * 2), e(".panel-compare .codelist-compare").html(r.join(""))
                    },
                    l = function() {
                        var r = [],
                            i = 0,
                            o = s.split(";"),
                            u = o.length,
                            a = 0,
                            f = [];
                        for (; a < u; a++) {
                            var l = "\u5355\u5f0f",
                                c = 1,
                                h = o[a].split("+"),
                                p = h[0],
                                d = h[1],
                                v = p.split(" ").length,
                                m = d.split(" ").length;
                            if (p.indexOf("$") > -1 && d.indexOf("$") > -1) {
                                var g = p.split("$"),
                                    y = d.split("$"),
                                    b = g[0].split(" ").length,
                                    w = g[1].split(" ").length,
                                    E = y[0].split(" ").length,
                                    S = y[1].split(" ").length;
                                l = "\u80c6\u62d6", c = t.number.combo(w, 5 - b) * t.number.combo(S, 2 - E)
                            } else if (p.indexOf("$") > -1 && d.indexOf("$") == -1) {
                                var g = p.split("$"),
                                    b = g[0].split(" ").length,
                                    w = g[1].split(" ").length;
                                l = "\u80c6\u62d6", c = t.number.combo(w, 5 - b) * t.number.combo(m, 2)
                            } else if (p.indexOf("$") == -1 && d.indexOf("$") > -1) {
                                var y = d.split("$"),
                                    E = y[0].split(" ").length,
                                    S = y[1].split(" ").length;
                                l = "\u80c6\u62d6", c = t.number.combo(v, 5) * t.number.combo(S, 2 - E)
                            } else v > 5 || m > 2 ? (l = "\u590d\u5f0f", c = t.number.combo(v, 5) * t.number.combo(m, 2)) : (l = "\u5355\u5f0f", c = 1);
                            f.push(l);
                            var x = {
                                plays: l,
                                count: c,
                                money: c * 2,
                                code: o[a],
                                red: p,
                                blue: d
                            };
                            i += c;
                            var T = '<li codes="<%=code%>"><div class="code"><b><%=plays%></b><b class="em"><%=red%> + <b class="blue"><%=blue%></b></b>  [<%=count%>\u6ce8,<em class="code-list-money"><%=money%></em>\u5143]</div></li>',
                                N = n.template(T);
                            r.push(N(x))
                        }
                        var C = n.uniq(f),
                            k;
                        C.length > 1 ? k = "\u6df7\u6295" : k = C[0], e(".dbq-plays").html(k), e(".dbq-count").html(i), e(".dbq-money").html(i * 2), e(".panel-compare .codelist-compare").html(r.join(""))
                    },
                    c = function() {
                        var r = [],
                            i = 0,
                            o = "\u5355\u5f0f",
                            u = 1,
                            a = s.split(";"),
                            f = a.length,
                            l = 0,
                            c = [];
                        for (; l < f; l++) {
                            var h = a[l];
                            if (h.indexOf("$") > -1) {
                                var p = h.split("$"),
                                    d = p[0].split(" ").length,
                                    v = p[1].split(" ").length;
                                o = "\u80c6\u62d6", u = t.number.combo(v, 7 - d)
                            } else {
                                var m = h.split(" "),
                                    g = m.length;
                                g > 7 ? (o = "\u590d\u5f0f", u = t.number.combo(g, 7)) : (o = "\u5355\u5f0f", u = 1)
                            }
                            c.push(o);
                            var y = {
                                plays: o,
                                count: u,
                                money: u * 2,
                                code: a[l],
                                red: a[l]
                            };
                            i += u;
                            var b = '<li codes="<%=code%>"><div class="code"><b><%=plays%></b><b class="em"><%=red%></b>  [<%=count%>\u6ce8,<em class="code-list-money"><%=money%></em>\u5143]</div></li>',
                                w = n.template(b);
                            r.push(w(y))
                        }
                        var E = n.uniq(c),
                            S;
                        E.length > 1 ? S = "\u6df7\u6295" : S = E[0], e(".dbq-plays").html(S), e(".dbq-count").html(i), e(".dbq-money").html(i * 2), e(".panel-compare .codelist-compare").html(r.join(""))
                    },
                    h = function(e, t, r) {
                        var i = {
                                1: [
                                    [6, 1]
                                ],
                                2: [
                                    [6, 0]
                                ],
                                3: [
                                    [5, 1]
                                ],
                                4: [
                                    [4, 1],
                                    [5, 0]
                                ],
                                5: [
                                    [3, 1],
                                    [4, 0]
                                ],
                                6: [
                                    [2, 1],
                                    [0, 1],
                                    [1, 1]
                                ]
                            },
                            s = {
                                red: [],
                                blue: []
                            },
                            o = t.split("+"),
                            u = o[0].split(" "),
                            a = o[1].split(" "),
                            e = e.split(";");
                        for (var f = 0, l = e.length; f < l; f++) {
                            var c = e[f].split(/[\+\$]/),
                                h, p, d, v;
                            c.length > 2 ? (h = c[0].split(" "), p = c[1].split(" "), d = c[2].split(" ")) : (h = [], p = c[0].split(" "), d = c[1].split(" "));
                            var m = n.intersection(h, u),
                                g = n.intersection(p, u),
                                y = n.intersection(d, a),
                                b = m.length,
                                w = g.length,
                                E = b + w,
                                S = y.length,
                                x = p.length - w + h.length - b,
                                T = d.length - S,
                                N = i[r],
                                C = !1;
                            for (var k = 0, L = N.length; k < L; k++)
                                if (E >= N[k][0] && x >= 6 - N[k][0] && (N[k][1] ? S == 1 : T > 0)) {
                                    s.red = m.concat(g.slice(0, N[k][0] - b)), N[k][1] && (s.blue = y), C = !0;
                                    break
                                }
                            if (C) break
                        }
                        return s
                    },
                    p = function(e, t, r) {
                        var i = {
                                1: [
                                    [5, 2]
                                ],
                                2: [
                                    [5, 1]
                                ],
                                3: [
                                    [5, 0],
                                    [4, 2]
                                ],
                                4: [
                                    [4, 1],
                                    [3, 2]
                                ],
                                5: [
                                    [4, 0],
                                    [3, 1],
                                    [2, 2]
                                ],
                                6: [
                                    [3, 0],
                                    [1, 2],
                                    [2, 1],
                                    [0, 2]
                                ]
                            },
                            s = {
                                red: [],
                                blue: []
                            },
                            o = t.split("+"),
                            u = o[0].split(" "),
                            a = o[1].split(" "),
                            e = e.split(";");
                        for (var f = 0, l = e.length; f < l; f++) {
                            var c = e[f].split("+"),
                                h = c[0].split("$"),
                                p = c[1].split("$"),
                                d, v, m, g;
                            h.length > 1 ? (d = h[0].split(" "), v = h[1].split(" ")) : (d = [], v = h[0].split(" ")), p.length > 1 ? (m = p[0].split(" "), g = p[1].split(" ")) : (m = [], g = p[0].split(" "));
                            var y = n.intersection(d, u),
                                b = n.intersection(v, u),
                                w = n.intersection(m, a),
                                E = n.intersection(g, a),
                                S = y.length,
                                x = b.length,
                                T = w.length,
                                N = E.length,
                                C = S + x,
                                k = T + N,
                                L = v.length - x + d.length - S,
                                A = g.length - N + m.length - T,
                                O = i[r],
                                M = !1;
                            for (var D = 0, P = O.length; D < P; D++)
                                if (C >= O[D][0] && L >= 5 - O[D][0] && (O[D][1] > 0 ? k >= O[D][1] : A >= 2 - O[D][1])) {
                                    s.red = y.concat(b.slice(0, O[D][0] - S)), O[D][1] > 0 && (s.blue = w.concat(E.slice(0, O[D][1] - T))), M = !0;
                                    break
                                }
                            if (M) break
                        }
                        return s
                    },
                    d = function(e, t, r) {
                        var i = {
                                1: [
                                    [7, 0]
                                ],
                                2: [
                                    [6, 1]
                                ],
                                3: [
                                    [6, 0]
                                ],
                                4: [
                                    [5, 1]
                                ],
                                5: [
                                    [5, 0]
                                ],
                                6: [
                                    [4, 1]
                                ],
                                7: [
                                    [4, 0]
                                ]
                            },
                            s = {
                                red: [],
                                blue: []
                            },
                            o = t.split("+"),
                            u = o[0].split(" "),
                            a = o[1].split(" "),
                            e = e.split(";");
                        for (var f = 0, l = e.length; f < l; f++) {
                            var c = e[f].split("$"),
                                h = e[f].split("$"),
                                p, d, v, m;
                            c.length > 1 ? (p = c[0].split(" "), d = c[1].split(" ")) : (p = [], d = c[0].split(" ")), h.length > 1 ? (v = h[0].split(" "), m = h[1].split(" ")) : (v = [], m = h[0].split(" "));
                            var g = n.intersection(p, u),
                                y = n.intersection(d, u),
                                b = n.intersection(v, a),
                                w = n.intersection(m, a),
                                E = g.length,
                                S = y.length,
                                x = b.length,
                                T = w.length,
                                N = E + S,
                                C = x + T,
                                k = d.length - S + p.length - E,
                                L = m.length - T + v.length - x,
                                A = i[r],
                                O = !1;
                            for (var M = 0, D = A.length; M < D; M++)
                                if (N >= A[M][0] && k >= 5 - A[M][0] && (A[M][1] > 0 ? C >= A[M][1] : L >= 1 - A[M][1])) {
                                    s.red = g.concat(y.slice(0, A[M][0] - E)), A[M][1] > 0 && (s.blue = b.concat(w.slice(0, A[M][1] - x))), O = !0;
                                    break
                                }
                            if (O) break
                        }
                        return s
                    },
                    v;
                o == "220051" ? v = e("#compare_ssq") : o == "120029" ? v = e("#compare_slt") : o == "220028" && (v = e("#compare_qlc")), t.lightbox.show({
                    html: v.html(),
                    cancel_sel: ".close",
                    drag_sel: ".panel-compare .hd",
                    callback: function() {
                        o == "220051" ? f() : o == "120029" ? l() : o == "220028" && c(), a()
                    }
                })
            },
            compare_sdp3: function(r, i) {
                var s = function() {
                        var n = {
                            LotID: r,
                            IssueCount: e('.method [type="radio"]:checked').val(),
                            TopCount: 5,
                            Chips: i
                        };
                        e(".compare-tips:eq(2)").show().siblings().hide(), e.post("/tools/getCompareResult", n, function(r) {
                            if (n.IssueCount != e('.method [type="radio"]:checked').val()) return;
                            if (r.code == 200) {
                                e(".compare-result h4 b").text(r.data.issueCount);
                                var r = r.data.result,
                                    i = [];
                                if (r.length == 0) i.push('<li class="ta-c muted">\u4f60\u9009\u62e9\u7684\u53f7\u7801\u5728\u6240\u9009\u7684\u671f\u6b21\u8303\u56f4\u5185\u8fd8\u6ca1\u6709\u4e2d\u8fc7\u5956\uff01</li>');
                                else
                                    for (var s = 0, o = r.length; s < o; s++) {
                                        i.push("<li>"), i.push("<p>"), i.push('<i class="ico ico-libefore"></i>'), i.push('<span class="number">' + r[s].levelName + '\uff1a<b class="red">' + r[s].total + "</b>\u6b21</span>"), i.push('<span class="bonus-hign">\u5355\u6ce8\u6700\u9ad8\u5956\u91d1\uff1a<b>' + t.number.currency(r[s].max) + "</b>\u5143</span>"), i.push('<i class="ico ico-liafter" title="\u70b9\u51fb\u5c55\u5f00"></i>'), i.push("</p>"), i.push('<div class="code-show">'), i.push('<span class="coner"></span>'), i.push("<ul>");
                                        var u = r[s].detail;
                                        for (var a = 0, f = u.length; a < f; a++) {
                                            var l = u[a].winno.split("+"),
                                                c = l[0].split(" ");
                                            i.push("<li>"), i.push('<span class="date">' + u[a].issue + "\u671f\u5f00\u5956</span>"), i.push('<span class="numlist" style="text-align:center">');
                                            for (var h = 0, p = c.length; h < p; h++) {
                                                var d = c[h];
                                                i.push('<em class="red">' + d + "</em> ")
                                            }
                                            i.push("</span>"), i.push('<span class="bonus">\u5956\u91d1\uff1a' + t.number.currency(u[a].bonus) + "\u5143</span>"), i.push("</li>")
                                        }
                                        a > 4 && i.push('<li class="muted">\u6700\u591a\u663e\u793a5\u671f<li>'), i.push("</ul>"), i.push("</div>"), i.push("</li>")
                                    }
                                e(".compare-list").html(i.join("")), e(".compare-tips").hide(), e(".compare-result").show(), e(".compare-list>li>p").on("click", function(t) {
                                    t.preventDefault(), e(this).parent().toggleClass("active").siblings().removeClass("active").find(".ico-liafter").attr("title", "\u70b9\u51fb\u5c55\u5f00"), e(this).find(".ico-liafter").attr("title", e(this).parent().hasClass("active") ? "\u70b9\u51fb\u6536\u8d77" : "\u70b9\u51fb\u5c55\u5f00")
                                })
                            }
                        })
                    },
                    o = function() {
                        e('.method [type="radio"]').on("change", function() {
                            var t = e(this).val() == "0" ? "\u5386\u53f2\u6240\u6709" : "\u6700\u8fd1" + e(this).val();
                            e(".compare-result").hide(), e(".compare-tips:eq(1)").find(".ta-c em").text(t).end().show().siblings().hide(), e(".panel-compare .btn-slt-ok").removeClass("disable")
                        }), e(".panel-compare .btn-slt-ok").on("click", function(t) {
                            t.preventDefault();
                            if (e(this).hasClass("disable")) return;
                            s(), e(this).addClass("disable")
                        })
                    },
                    u = function(r, i) {
                        var s = [],
                            o = 0,
                            u = "\u76f4\u9009\u5355\u5f0f",
                            a = i.split(";"),
                            f = a.length,
                            l = 0,
                            c = [];
                        for (; l < f; l++) {
                            var h = 0,
                                p = "Z1",
                                d = a[l],
                                v = d.split(",");
                            if (t.QFilter.options.zuxuan) {
                                p = "Z3";
                                var m = 0;
                                m += (v[0] == v[1] ? 1 : 0) + (v[0] == v[2] ? 1 : 0) + (v[1] == v[2] ? 1 : 0);
                                if (m == 0) p = "Z6";
                                else {
                                    if (m != 1) continue;
                                    p = "Z3"
                                }
                            }
                            switch (p) {
                                case "Z1":
                                    var g = v[0].length * 1,
                                        y = v[1].length * 1,
                                        b = v[2].length * 1;
                                    g == 1 && y == 1 && b == 1 ? (u = "\u76f4\u9009\u5355\u5f0f", h = 1) : (u = "\u76f4\u9009\u590d\u5f0f", h = g * y * b);
                                    break;
                                case "Z3":
                                    u = "\u7ec4\u4e09\u5355\u5f0f", h = 1;
                                    break;
                                case "Z6":
                                    u = "\u7ec4\u516d\u5355\u5f0f", h = 1;
                                    break;
                                case "S1":
                                    u = "\u76f4\u9009\u548c\u503c";
                                    var w = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 63, 69, 73, 75, 75, 73, 69, 63, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1],
                                        v = d.split(","),
                                        E = v.length,
                                        S = 0;
                                    for (; S < E; S++) h += w[v[S]];
                                    break;
                                case "S3":
                                    u = "\u7ec4\u4e09\u548c\u503c";
                                    var x = [0, 1, 2, 1, 3, 3, 3, 4, 5, 4, 5, 5, 4, 5, 5, 4, 5, 5, 4, 5, 4, 3, 3, 3, 1, 2, 1, 0],
                                        v = d.split(","),
                                        E = v.length,
                                        T = 0;
                                    for (; T < E; T++) h += x[v[T]];
                                    break;
                                case "S6":
                                    u = "\u7ec4\u516d\u548c\u503c";
                                    var N = [0, 0, 0, 1, 1, 2, 3, 4, 5, 7, 8, 9, 10, 10, 10, 10, 9, 8, 7, 5, 4, 3, 2, 1, 1, 0, 0, 0],
                                        v = d.split(","),
                                        E = v.length,
                                        C = 0;
                                    for (; C < E; C++) h += N[v[C]]
                            }
                            c.push(u);
                            var k = {
                                plays: u,
                                count: h,
                                money: h * 2,
                                code: a[l],
                                red: d
                            };
                            o += h;
                            var L = '<li codes="<%=code%>"><div class="code"><b><%=plays%></b><b class="em"><%=red%></b>  [<%=count%>\u6ce8,<em class="code-list-money"><%=money%></em>\u5143]</div></li>',
                                A = n.template(L);
                            s.push(A(k))
                        }
                        var O = n.uniq(c),
                            M;
                        O.length > 1 ? M = "\u6df7\u6295" : M = O[0], e(".dbq-plays").html(M), e(".dbq-count").html(o), e(".dbq-money").html(o * 2), e(".panel-compare .codelist-compare").html(s.join(""))
                    },
                    a;
                r == "110033" ? a = e("#compare_p3") : r == "210053" && (a = e("#compare_sd")), t.lightbox.show({
                    html: a.html(),
                    cancel_sel: ".close",
                    drag_sel: ".panel-compare .hd",
                    callback: function() {
                        u(r, i), o()
                    }
                })
            }
        };
    e.extend(t.QFilter, r)
})();